<table>
	<thead>
		<th width="20">PID</th>
		<th width="60">CPU <span>(Time)</span></th>
		<th width="60">Memory</th>
		<th width="100">Process</th>
		<th>Parameters</th>
	</thead>
	<tbody>
<?
	$odd = false;
	foreach ($device->snmp->find('HOST-RESOURCES-MIB','hrSWRunIndex') AS $oid=>$index) {
		$process = $device->snmp->find('HOST-RESOURCES-MIB','hrSW([a-zA-z]+).'.$index,true);
		$process= (object)$process[$index];
		echo '<tr class="'.($odd?'odd':'').'">';
			echo '<td align="right">'.$process->hrSWRunIndex.'</td>';
			echo '<td align="right">'.formatCPUTime($process->hrSWRunPerfCPU).'</td>';
			echo '<td width="100" align="right">'.$nms->formatBytes($process->hrSWRunPerfMem*1024).'</td>';
			echo '<td align="right"><b>'.$process->hrSWRunName.'</b></td>';
			echo '<td>'.$process->hrSWRunParameters.'</td>';
		echo '</tr>';
		$odd = !$odd;
	}




?>	
	
	
	</tbody>	
</table>


<?

function formatCPUTime($value){
	$hours = 0;
	$minutes = 0;
	$decimals = 0;
	if ($value > 0) {
		$decimals = substr($value,-2);
		$minutes = substr($value,0,strlen($value)-2);
		$hours = floor($minutes/60);
		$minutes = $minutes-($hours*60);
	}
	
	

	return ($hours>0?$hours.':':'').$minutes.'.'.$decimals;
}
